(function() {
	// 通过邮箱找回密码
	function _find_pwd_by_email(email) {
		var url = appConfig.open["find_paw_email_user"];
		if (!url) {
			alert("error", "账号类型错误");
			return;
		}
		coAjax.post(url, {
			email: email
		}, function() {
			alert("success", "成功提交申请密码");
			App.set("$Cache.find_password.step", "step_b");
		});
	};
	// 通过手机找回密码
	function _find_pwd_by_phone(mobile_phone) {
		var url = appConfig.open["find_paw_phone_user"];
		if (!url) {
			alert("error", "账号类型错误");
			return;
		}
		coAjax.post(url, {
			mobile_phone: mobile_phone
		}, function() {
			alert("success", "成功提交申请密码");
			App.set("$Cache.find_password.step", "step_b");
		});
	};

	// 提交申请
	App.set("$Event.find_password.confirm", function() {
		var user_bind = App.get("$Cache.find_password.user_bind");
		if (!user_bind) {
			alert("warn", "请输入您账号绑定的手机号或电子邮箱！！！");
			return;
		};
		if (user_bind.indexOf("@") == -1) {
			_find_pwd_by_phone(user_bind);
		} else {
			_find_pwd_by_email(user_bind);
		};
	});

	// 提交修改
	App.set("$Event.find_password.update_password", function() {
		coAjax.put(appConfig.open.reset_paw_by_find_paw_id + App.get("$Cache.find_password.code"), {
			paw: App.get("$Cache.find_password.new_password"),
			confirm_paw: App.get("$Cache.find_password.re_password")
		}, function() {
			alert("success", "密码修改成功");
			App.set("$Cache.find_password.step", "step_c");
		});
	});

})();